home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1266 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.9 KB  |  79 lines

  1. Path: news.ultranet.com!usenet
  2. From: Ken Brady <kbrady@ultranet.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Why can't I use this function prototype????
  5. Date: Tue, 9 Jan 1996 20:59:32 EST
  6. Organization: UltraNet Communications, Inc.
  7. Message-ID: <60ju5934@kbrady.ultranet.com>
  8. Reply-To: Ken Brady <kbrady@ultranet.com>
  9. NNTP-Posting-Host: 205.246.13.244
  10. X-Mailer: Post Road Mailer (Green Edition Ver 1.05a)
  11.  
  12. I have a header file with something like: 
  13.  
  14. /*  pm_app.hpp */ 
  15. Class PmApplication { 
  16.   PmApplication();
  17.   .... //member and method definitions here 
  18. }; 
  19.  
  20. PmApplication *Application();    //a typical function prototype?? 
  21. // other function prototypes here 
  22. // end pm_app.hpp 
  23.  
  24. My implementation is, of course, hidden from users of the header file: 
  25.  
  26. /*  pm_app.cpp    */ 
  27. PmApplication *App=NULL;    //a global variable 
  28.  
  29. PmApplication *Application() {return App;} 
  30.  
  31. PmApplication::PmApplication()
  32. { App = this;}
  33.  
  34. ... // more implementations 
  35.  
  36.  
  37.  
  38. So, I try to use this function:
  39.  
  40. /* myapp.cpp  */ 
  41. #include "pm_app.hpp" 
  42.  
  43. void MyProcedure()  
  44. { ... 
  45.   PmApp *A=Application();        //won't compile!! 
  46.   ... 
  47.  
  48. The compiler error is: 
  49. myapp.cpp(53): Error! E043: (col 1) static function 'Application' has   
  50. not been defined  
  51. myapp.cpp(53): Note! N392: (col 1) 'PmApp * Application( void )'   
  52. defined in: d:\c\lib\pm_app.hpp(55) (col 15)  
  53.  
  54. Why has the compiler singled out this function prototype as being   
  55. somehow different from all of my other function prototypes?  Why is it  
  56. 'static'? 
  57.  
  58. I've tried implementing the global variable directly, i.e., defining   
  59. the global variable 'PmApplication *App=NULL' in the header file.    
  60. Then, the linker tells me that it has redefined App for every file that   
  61. includes pm_app.hpp.  How else can I implement a global variable? 
  62.  
  63. Help appreciated ... 
  64.  
  65.  
  66.  
  67.  
  68.      __________ `-'. 
  69.   /| o  o O   o  ___: 
  70.     \ O ____0  / 
  71.      (//W   || 
  72.      |||    ||     -CyberPriestess- 
  73.      ""     "" 
  74.  DONT HAVE A COW, MAN 
  75.  
  76.  
  77.  
  78.